// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT

#include "../jpg_aigc_meta_clib/cn_jpg_aigc_meta_sdk.h"
#include <stdio.h>
#include <string.h>

void meta_callback(void *context, int64_t error_code, const char *error_desc, const char *meta_content) {
    if (error_code == 0) {
        printf("Success! Meta content: %s\n", meta_content);
    } else {
        printf("Error! Code: %lld, Description: %s\n", error_code, error_desc);
    }
}

int main() {
    const char *original_file = "../test.jpg";
    const char *output_file = "../test_with_meta.jpg";

    printf("Attempting to write metadata...\n");
    write_meta(
        original_file,
        output_file,
        "ExamplePropagator",
        "1",
        "propagator-id-12345",
        true, // as_producer = true
        NULL,
        meta_callback
    );

    printf("Attempting to read metadata from new file...\n");
    read_meta(
        output_file,
        NULL,
        meta_callback
    );

    return 0;
}